<?php

declare(strict_types=1);

namespace App\Music\Model;

use App\Model\MusicSongs;
use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

/**
 * @property int $id 
 * @property int $source_id 来源id
 * @property string $name 艺术家名称
 * @property string $avatar 艺术家头像 URL
 * @property string $desc 艺术家简介
 * @property string $gender 性别
 * @property string $nationality 国籍
 * @property string $birth_date 出生日期
 * @property string $genre 主要音乐流派
 * @property string $social_media 社交媒体链接
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property string $deleted_at 删除时间
 */
class MusicArtist extends MineModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'music_artist';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'source_id', 'name', 'avatar', 'desc', 'gender', 'nationality', 'birth_date', 'genre', 'social_media', 'created_at', 'updated_at', 'deleted_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'source_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

//    protected array $casts = [
//        'platform' => 'json'
//    ];

    /**
     * 歌曲列表
     * */
    public function song()
    {
        return $this->belongsToMany(MusicSong::class, 'music_song_artist_relations', 'artist_id', 'song_id');
    }

}
